/*
 * @lc app=leetcode.cn id=122 lang=typescript
 *
 * [122] 买卖股票的最佳时机 II
 */

// @lc code=start
function maxProfit(prices: number[]): number {
    let diff, sum = 0
    for(let i = 1, n = prices.length; i < n; i++) {
        diff = prices[i] - prices[i-1]
        if (diff > 0) sum += diff
    }
    return sum
};
// @lc code=end

